//
//  LMDownLoadController.m
//  EPA
//
//  Created by lanou3g on 16/4/28.
//  Copyright © 2016年 liman. All rights reserved.
//

#import "LMDownLoadController.h"
#import "DownLoadManager.h"
#import "LMDownLoadCell.h"
@interface LMDownLoadController ()

@end

@implementation LMDownLoadController

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self.tableView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.navigationItem.title = @"下载列表";
    [self.tableView registerNib:[UINib nibWithNibName:@"LMDownLoadCell" bundle:nil] forCellReuseIdentifier:@"LMDownLoadCell"];
    //    接收通知
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(reload) name:@"downloadReloadData" object:nil];
}
- (void)reload{
    [self.tableView reloadData];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [DownLoadManager shareManager].array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    LMDownLoadCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LMDownLoadCell" ];

    cell.indexPath = indexPath;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 400;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self dismissViewControllerAnimated:YES completion:nil];
}


@end
